package com.CGFrame.struts.bean.sector;

import java.util.*;
import java.sql.*;
import com.CGFrame.struts.bean.*;
import com.CGFrame.struts.POJOs.*;

import org.apache.struts.util.*;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

public class SectorBean {
	
	ProjectOperate pop = ProjectOperateFactory.getprojectOperate();
	public Iterator CompanySectors(Company c)
	{
		return c.getSectors().iterator();
	}
	
	public List QuerySectors(int SectorID)
	{
		return pop.Query("Sector", "parentId,"+SectorID, "sectorId", "ASC");
	}
	public void UpdateSector(int ob_id, int leader_id) 
	{
		// Ask for a session using the JDBC information we've configured
		
		Sector sec = (Sector)pop.UniqueQuery("Sector", "sectorId,"+ob_id);	
		sec.setLeaderId(leader_id);
		pop.saveObject(sec);
	}//Update Sector
	public HashSet getEmployeeNameBySectorId(String id){
		HashSet<String> set=new HashSet<String>();
		Sector sector=(Sector)pop.UniqueQuery("Sector", "sectorId,"+id);
		Set emps=sector.getEmployees();
		Employee emp;
		for(Iterator iter=emps.iterator();iter.hasNext();){
			emp=(Employee)iter.next();
			set.add(emp.getEmpName());
		}
		return set;
	}
}